import {
    createBrowserRouter, RouterProvider
} from "react-router-dom";


import Home from "./ui/Home.jsx";
import Menu,{ loader as menuLoader } from "./features/menu/Menu.jsx";
import AppLayout from "./ui/AppLayout.jsx";
import Error from "./ui/Error.jsx";

import Cart from "./features/cart/Cart.jsx";
import Order,{loader as orderLoader} from "./features/order/Order.jsx";
import {action as updateOrderAction} from './features/order/UpdateOrder.jsx';
import CreateOrder,{action as createOrderAction}
    from "./features/order/CreateOrder.jsx";


const router =  createBrowserRouter([
    {
      element:<AppLayout />,

        children:[
            {
                path:"/",
                element:<Home />
            },
            {
                path:"/menu",
                element:<Menu />,
                loader: menuLoader,
                errorElement: <Error />,
            },
            {
                path:"/cart",
                element:<Cart />
            },
            {
                path:"/order/:orderId",
                element:<Order />,
                loader:orderLoader,
                errorElement: <Error />,
                action:updateOrderAction,
            },
            {
                path:"/order/new",
                element:<CreateOrder />,
                action:createOrderAction
            }
        ]
    },

]);
function App() {

  return (
    <div>
        <RouterProvider router={router} />;
    </div>
  )
}

export default App
